package org.wishwork.api.base.shop;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.wishwork.api.Base;

/**
 * @description: 店铺请求对象
 * @author: WangYX
 * @create: 2022-04-02 15:07
 * @Version: 1.0.0
 **/
@EqualsAndHashCode
@Getter
public class ShopRequest extends Base {

    /**
     * 店铺主账号，不支持模糊查询，非必填项，默认查所有
     */
    private String nicks;

    public ShopRequest(Integer pageIndex, Integer pageSize, String nicks) {
        super(pageIndex, pageSize);
        this.nicks = nicks;
    }

    public static Builder builder() {
        return new Builder();
    }

    @Override
    public Builder toBuilder() {
        return new Builder().pageIndex(this.pageIndex).pageSize(this.pageSize).nicks(this.nicks);
    }

    public static class Builder extends Base.Builder<Builder, ShopRequest> {

        private String nicks;

        @Override
        public Builder pageIndex(Integer pageIndex) {
            this.pageIndex = pageIndex;
            return this;
        }

        @Override
        public Builder pageSize(Integer pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        public Builder nicks(String nicks) {
            this.nicks = nicks;
            return this;
        }

        @Override
        public ShopRequest build() {
            this.pageIndex = this.pageIndex == null ? 1 : this.pageSize < 0 ? 1 : this.pageIndex;
            this.pageSize = this.pageSize == null ? 100 : this.pageSize < 0 ? 100 : this.pageSize;
            return new ShopRequest(this.pageIndex, this.pageSize, this.nicks);
        }
    }
}
